--- title: H Parameter keywords: fastai sidebar: home_sidebar summary: "A reader for the binary H parameter map" description: "A reader for the binary H parameter map" nb_path: "05_hpar.ipynb" ---
hpar_path
Size in bytes:
size = hpar_path.stat().st_size
size
Scaling down 80 lats to 70:
n_lats = 20480 / 80 * 70
n_lats
npix = 46080 * int(n_lats)
npix
multiply by 32 bits, divide by 8 to get bytes:
expected_bytes = npix * 32 / 8
expected_bytes
Ratio:
size / expected_bytes
npix = 46081 * (int(n_lats) + 1)
npix
expected_bytes = npix * 32 / 8
size / expected_bytes
lats = memmap_binary(lats_path)
lats[0], lats[-1]
lons = memmap_binary(lons_path)
lons[:, 0], lons[:, -1]
with np.printoptions(precision=10):
print(lons[0])
with np.printoptions(precision=10):
print(lons[:, 0])
np.printopt
with np.printoptions(precision=20):
print(lons[0])
np.linspace(-70, 70, int(n_lats))
half_pixel_degree = 1 / 128 / 2
half_pixel_degree
with_n_plus_1 = np.linspace(
-70 - half_pixel_degree, 70 - half_pixel_degree, int(n_lats) + 1
)
from_data = lats[
:,
0,
][::-1]
n = len(from_data)
%matplotlib widget
from_data[:10]
with_n_plus_1
H = HReader()
H.img
H.get_H_by_coord(20, 50)
H.img.sel(lat=slice(21, 20), lon=slice(120,121)).hvplot()
H.convert_to_lon180()
H.img
H.get_H_by_coord(20, 70)
lons = memmap_binary(lons_path)
lons.shape
pd.Series(lons[:, 0]).value_counts()
pd.Series(lons[:, -1]).value_counts()
H = memmap_binary(hpar_path)
H.shape
H[:, 0][:10]
H[:, -1][:10]
H = read_hpar_binary()
H.isel(lon=0).hvplot() * H.isel(lon=-1).hvplot()
(H.isel(lon=0)[1:] - H.isel(lon=-1)[:-1]).compute().data
left = H.isel(lon=-1)[:-1].compute().data
right = H.isel(lon=0)[1:].compute().data
pd.Series(left - right).value_counts()
17326 / left.shape[0]
%matplotlib widget
fig, ax = plt.subplots()
ax.plot(H[:, 0], label="left")
ax.plot(H[:, -1], label="right")
H[:, 0][:10]
H[:, -1][:10]
H.lon.diff("lon") / 2
H = read_hpar_binary()
import hvplot.xarray
H.isel(lon=0).hvplot() * H.isel(lon=-1).hvplot()
rate = 47
rate * 8
arr_x = []
arr_y = []
for i in range(5):
arr_x.append(np.sort(np.random.uniform(size=20)))
arr_y.append(np.sort(np.random.uniform(size=20)))
plt.figure()
for x, y in zip(arr_x, arr_y):
plt.plot(x, y)